const index = require('../app/controllers'),
    multer = require('multer'),
    user = require('../app/controllers/user')

module.exports = function(app, passport) {
    app.get('/', index.index)
    app.post('/test', index.testPost)

    app.get('/login', user.login)
    app.post('/login/check', user.check)

    app.get('/auth/tumblr', passport.authenticate('tumblr'))
    app.get('/auth/tumblr/callback',
        passport.authenticate('tumblr', { failureRedirect: '/login', session: false }),
        function(req, res) {
            // Successful authentication, redirect home.
            res.redirect('/');
        }
    )

    var storage = multer.diskStorage({
        destination: function(req, file, cb) {
            cb(null, 'uploads/')
        },
        filename: function(req, file, cb) {
            cb(null, file.originalname)
        }
    })
    app.post('/upload', multer({ storage }).single('pic'), index.upload)
}
